package com.dinadi.yidi.ui.activity;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dinadi.yidi.R;
import com.dinadi.yidi.base.BaseActivity;

/**
 * author: JiaYu.He
 * Date: 2017/7/10   支付结果
 * Time: 14:20
 */
public class PaymentResultsActivity extends BaseActivity {
    private View view;
    private ImageView see_order_information;
    private TextView tvTitle, tv_pay_price, tv_point;
    private String orderId, cartItemIds;

    @Override
    protected View getLayout() {
        view = LayoutInflater.from(PaymentResultsActivity.this).inflate(R.layout.activity_payment_results, null);
        return view;
    }

    @Override
    protected void noWifiRefresh() {

    }

    @Override
    protected void initView() {
        changePager(2);
        tvTitle = (TextView) view.findViewById(R.id.text_title);
        tvTitle.setText(getResources().getString(R.string.text_pay_result));
        see_order_information = (ImageView) view.findViewById(R.id.see_order_information);
        tv_pay_price = (TextView) view.findViewById(R.id.tv_pay_price);
        tv_point = (TextView) view.findViewById(R.id.tv_point);
    }

    @Override
    protected void initListener() {
        registerClickListener(see_order_information);
    }

    @Override
    protected void initData() {
        Intent intent = getIntent();
        orderId = intent.getStringExtra("orderId");
        String totalPrice = intent.getStringExtra("totalPrice");
        tv_pay_price.setText(totalPrice);
        cartItemIds = intent.getStringExtra("cartItemIds");
        String point = intent.getStringExtra("point");
        tv_point.setText("+" + point + "积分");
    }

    @Override
    protected void clickEvent(View v) {
        switch (v.getId()) {
            case R.id.see_order_information:
                if (cartItemIds != null) {
                    Intent intent = new Intent();
                    intent.setClass(PaymentResultsActivity.this, MyOrderActivity.class);
                    intent.putExtra("orderId", orderId);
                    startActivity(intent);
                    PaymentResultsActivity.this.finish();
                } else {
                    /*查看订单*/
                    Intent intent = new Intent(PaymentResultsActivity.this, ProductOrderDetailsActivity.class);
                    intent.putExtra("orderId", orderId);
                    startActivity(intent);
                    PaymentResultsActivity.this.finish();
                }

                break;

            default:
                break;
        }
    }
}
